//
//  LongitudeSelectViewController.m
//  ContactManager
//
//  Created by mzhou19 on 11/13/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "LongitudeSelectViewController.h"


@implementation LongitudeSelectViewController

@synthesize pickerView;
@synthesize longitudePick;
@synthesize longitudeShow;
@synthesize intergerPart;
@synthesize fractionPart;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 2;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    if(component == 0)
        return [intergerPart count];
    else
        return [fractionPart count];
}
-(IBAction)longitudePickButtonPressed
{
    NSString *msg = [NSString stringWithFormat: @"longitude: %@.%@",
                     [intergerPart objectAtIndex:[pickerView selectedRowInComponent:0]],
                     [fractionPart objectAtIndex:[pickerView selectedRowInComponent:1]]];
    
	NSLog(@"%@,%@",[intergerPart objectAtIndex:[pickerView selectedRowInComponent:0]],[fractionPart objectAtIndex:[pickerView selectedRowInComponent:1]]);
	longitudeShow.text = msg;
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component 
{
	
    switch (component) 
	{
        case 0:
            return [intergerPart objectAtIndex:row];
            break;
        case 1:
            return [fractionPart objectAtIndex:row];
            break;
	}
    return nil;
}


- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"longitude Setting";
    intergerPart =[[NSArray alloc] initWithObjects:@"1",@"2",@"3",@"4",nil];
    fractionPart = [[NSArray alloc] initWithObjects: @"1",@"2",@"3",@"4",nil];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
